<?php
/**
 * Created by PhpStorm.
 * User: qttx
 * Date: 2019/5/31
 * Time: 9:20
 */
namespace app\admin\model;

class BalabceLogModel extends BaseModel
{
    protected $table = "xst_balance_log";
    protected $rule = [
        'id' => '',
    ];
    protected $msg = [
        'id' => '',
    ];
    /**
     * 会员流水日志
     */
    public function assetslog($condition=1)
    {
        if(input('get.sub')){
            $balance_type = input('balance_type');
            $type = input('type');
            if(!empty($balance_type)){
                $condition .= "  and (balance_type = $balance_type)";
            }
            if(!empty($type)){
                $condition .= "  and (b.type  = $type)";
            }

        }
        $res = $this->field('b.*,u.nickname')->alias('b')->join('xst_user u','b.uid = u.id')->where($condition)->order('createtime desc')->paginate(10,false,['query'=>request()->param()]);
        return $res;
    }
    /**
     * 会员流水多删
     */
    public function assets_dell()
    {
        $id = request()->post('id');
        $res = $this->where('id','in',$id)->delete();
        return $res;
    }
}